<?php

if (!defined('BASEPATH'))
exit('No direct script access allowed');

class Ourservices extends MX_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 * 	- or -
	 * 		http://example.com/index.php/welcome/index
	 * 	- or -
	 * Since this controller is set as the default controller in
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function Ourservices() {
		parent::__construct();
		$this->load->model('lookupmodel');
		$this->load->model('helpermodel');
		//check is logged in
		$this->load->model('languagemodel');
		$this->load->model('projects/mdl_projectsmodel');
		$this->language = $this->languagemodel->is_language_using();
		$this->load->helper('MY_url_helper');
		$this->load->helper('text');
		
		$this->load->model('banners/bannermodel');
	}

	public function index() {
		$this->lang->load('ourservices/ourservices', $this->config->item('language'));

		//SEO
		$data['title'] = $this->lang->line('our_services_text_title');
		$data['description'] = $this->lang->line('our_services_text_description');
		$data['keywords'] = $this->lang->line('our_services_text_keywords');

		$data['breadcrumbs'] = array();

		$data['breadcrumbs'][] = array(
			'text'      => '',
			'href'      => base_url()
		);

		$data['breadcrumbs'][] = array(
			'text'      => $this->lang->line('text_heading'),
			'href'      => base_url() . 'our-services.html'
		);

		$data['module'] = "ourservices";
		$data['view_file'] = "ourservices";

		$this->load->model('mdl_ourservices');

		$id = 0;

		$results = $this->mdl_ourservices->getOurService($id, $this->config->item('config_language_id'), $this->config->item('market'));

		$data['ourteams'] = array();
		if($results) {
			foreach ($results as $result) {
				if(!empty($result->ImageUrl)) {
					$imageUrl = $this->config->item('HTTP_ARTICLE_MEDIA_IMAGE') . $result->ImageUrl;
				} else {
					$imageUrl = $this->config->item('HTTP_IMAGE') . 'photos/buyer-guide.png';
				}
					
				$data['ourteams'][] = array(
					'Href'			=> base_url() . 'our-services/detail/' . $result->Post_ID,
					'Post_ID'		=> $result->Post_ID,
					'Title'			=> $result->Title,
					'Summary'		=> $result->Summary,
					'PostContent'	=> $result->PostContent,
					'Cover'			=> $imageUrl
				);
			}
		}
		
		//get banner for right side
		$data['banner'] = $this->bannermodel->getBanners('Our Team', $this->config->item('market'), $this->config->item('config_language_id'));

		echo Modules::run('template/default_template', $data);
	}

	public function detail($id) {
		$this->lang->load('ourservices/detail', $this->config->item('language'));

		//SEO
		$data['title'] = $this->lang->line('our_services_text_title');
		$data['description'] = $this->lang->line('our_services_text_description');
		$data['keywords'] = $this->lang->line('our_services_text_keywords');

		$data['text_heading'] = $this->lang->line('text_heading');

		$data['breadcrumbs'] = array();

		$id = $this->uri->segment(3);

		$data['breadcrumbs'][] = array(
			'text'      => '',
			'href'      => base_url()
		);

		$data['breadcrumbs'][] = array(
			'text'      => $this->lang->line('text_our_team'),
			'href'      => base_url() . 'our-services.html'
		);

		$data['breadcrumbs'][] = array(
			'text'      => $this->lang->line('text_heading'),
			'href'      => base_url() . 'our-services/detail/' . $id
		);

		$data['module'] = "ourservices";
		$data['view_file'] = "detail";

		$this->load->model('mdl_ourservices');

		$result = $this->mdl_ourservices->getOurService($id, $this->config->item('config_language_id'), $this->config->item('market'));

		$data['ourteam'] = array();
		if($result) {
			if(!empty($result->ImageUrl)) {
				$imageUrl = $this->config->item('HTTP_ARTICLE_MEDIA_IMAGE') . $result->ImageUrl;
			} else {
				$imageUrl = $this->config->item('HTTP_IMAGE') . 'photos/buyer-guide.png';
			}
				
			$data['ourteam'] = array(
			'Post_ID'		=> $result->Post_ID,
			'Title'			=> $result->Title,
			'Summary'		=> $result->Summary,
			'PostContent'	=> $result->PostContent,
			'Cover'			=> $imageUrl
			);
		} else {
			redirect(base_url() . 'error_404', 'refresh');
		}
		
		//get banner for right side
		$data['banner'] = $this->bannermodel->getBanners('Our Team', $this->config->item('market'), $this->config->item('config_language_id'));

		echo Modules::run('template/one_col', $data);
	}

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */